<?php
// +----------------------------------------------------------------------
// | Description: 岗位
// +----------------------------------------------------------------------
// | Author: linchuangbin <linchuangbin@honraytech.com>
// +----------------------------------------------------------------------

namespace app\admin\model;

use app\admin\model\Common;

class ServiceTime extends Common
{

    /**
     * 为了数据库的整洁，同时又不影响Model和Controller的名称
     * 我们约定每个模块的数据表都加上相同的前缀，比如微信模块用weixin作为数据表前缀
     */
    protected $name = 'admin_service_time_log';

    /**
     * [getDataList 获取列表]
     * @linchuangbin
     * @DateTime  2017-02-10T21:07:18+0800
     * @return    [array]
     */
    public function getDataList($keywords,$page,$limit,$param)
    {
        $map = [];
        if ($keywords) {
            $map['name'] = ['like', '%'.$keywords.'%'];
        }
        if($param['payType']){
            $map['pay_type'] = $param['payType'];
        }
        if(!empty($param['cid'])||$param['cid']=="0"){
            $map['company'] = $param['cid'];
        }
        if ($param['sTime']) {
            $map['create_time'] = ['egt',$param['sTime']];
            $map['create_time'] = ['elt',$param['eTime']];
        }
        $dataCount = $this->alias('admin_service_time_log')->where($map)->count('id');
        $data['list'] = $this->where($map)->page($page, $limit)->select();
        $data['dataCount'] = $dataCount;
        return $data;
    }
}